require 'time'

class RequestHistoryTable

  def initialize(table)
    @table = table
  end

  def get_resolution_info
    r = {}
    rows = @table.trs.to_a
    resolved_row_index = rows.index { |r| r.text =~ /Resolved by/ }

    if resolved_row_index
      row_above = rows[resolved_row_index-1]
      captures = row_above.text.scan(/(.+) by (.+)/)[0]
      r[:resolved_on] = Time.parse captures[0]
      r[:resolved_by] = captures[1]
    end

    r[:history] = @table.text
    r
  end

end